export default class Stack<T> {
    private data: T[] = [];

    public get length() {
        return this.data.length;
    }

    public push(item: T) {
        this.data.push(item);
    }

    public pop(): T | undefined {
        return this.data.pop();
    }

    public top(): T | undefined {
        return this.data[0];
    }

    public isEmpty() {
        return 0 === this.length;
    }

    public clear() {
        this.data.splice(0, this.length);
    }
}